#ifndef TRANSITION_H
#define TRANSITION_H

#include <QWidget>
#include <QTimer>


namespace Hydra_Transition {

typedef enum _transition_state{
    INIT,                                           // 初始态
    ENTER_DEPOT,                                    // 进入车辆段
    ENTER_GARAGE,                                   // 进入停车库线
    INLOCATION_OR_IN_DEPORT,                        // 未定位或在车辆段内形式
    OPEN_WITH_CONFIRM                               // 开口模式下带确认
}TRANSITION_STATE;

}


using namespace Hydra_Transition;

class Transition : public QWidget
{
    Q_OBJECT

public:
    Transition(QWidget *parent = 0);

    void setInterval(quint16 interval);
    void setState(TRANSITION_STATE state);

public slots:
    void refresh();

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent(QResizeEvent *event);
    void initParam();
    void drawImage(QPainter *pPainter);
    void drawRect(QPainter *pPainter);
    void drawTrain(QPainter *pPainter);
    void drawOpenMode(QPainter *pPainter);


private:
    QTimer mTimer;
    QPoint mCenterPoint;
    TRANSITION_STATE mState = TRANSITION_STATE::INIT;
    QColor mTrainColor = QColor(212, 212, 212);
    QColor mDeportColor = QColor(255, 242, 0);
    QColor mGarageColor = QColor(45, 144, 51);
    quint8 mImageHeightProportion = 80;
    quint8 mImageWidthProportion = 50;
    QRect mOutRect;
    quint8 mOutRectLineWidth = 4;
    QRect mTrainRect;
    QPoint mTrainLeft;
    QPoint mTrainRight;
    QRect mWheelLeft;
    QRect mWheelRight;
    QRect mEyeRect;
    QPoint mLeft;                                                           // 开口模式左侧点
    QPoint mTopRight;                                                       // 开口模式右侧上方点
    QPoint mBottomRight;                                                    // 开口模式右侧下方点
};

#endif // TRANSITION_H
